package com.xyj.rxhui.week00;

import com.xyj.common.ListNode;

/**
 * @author GuXiaoYao
 * @version 1.0.0
 * @since 2021/12/6
 */
public class T7 {
    public ListNode getIntersectionNode(ListNode headA, ListNode headB) {

        ListNode p1=headA;
        ListNode p2=headB;

        while(p1!=p2) {
            if(p1!=null){
                p1=p1.next;
            }else {
                p1=headB;
            }
            if(p2!=null){
                p2=p2.next;
            }else {
                p2=headA;
            }
        }
        return p1;

    }
}
